let vm=new Vue({
    el:'#main',
    data:{
        service:{},
        flag:{},
        pwd:''
    },
    methods:{
        checkAccountName:function (aname,id) {
            axios({
                url:'service/checkAccountName',
                params:{"aname":aname,"id":id}
            }).then(rs=>{
                if (rs.data=="0") {
                    $(".validate_msg_long").eq(0).text("没有此账务账号，请重新录入。");
                    $(".required").eq(1).text("*");
                    this.flag.checkAccountName=false;
                    return
                }
                $(".validate_msg_long").eq(0).text("");
                $(".required").eq(1).text("√");
                this.flag.checkAccountName=true

            })
        },
        checkAccountIdcardNo:function (id) {
            axios({
                url:'service/checkAccountIdcardNo',
                params:{"id":id}
            }).then(rs=>{
                if (rs.data==0) {
                    $(".validate_msg_short").eq(0).text("没有此身份证号，请重新录入。");
                    $(".required").eq(0).text("*");
                    this.flag.checkAccountIdcardNo=false;
                    return
                }
                $(".validate_msg_short").eq(0).text("");
                $(".required").eq(0).text("√");
                this.flag.checkAccountIdcardNo=true
            })
        },
        checkUnixHost:function (unixHost) {
            axios({
                url:'service/checkUnixHost',
                params:{"unixHost":unixHost}
            }).then(rs=>{
                if (rs.data==0) {
                    $(".required").eq(2).text("*");
                    this.flag.checkUnixHost=false;
                    return
                }
                $(".required").eq(2).text("√");
                this.flag.checkUnixHost=true
            })
        },
        checkOsuserName:function (osUsername) {
            axios({
                url:'service/checkOsUsername',
                params:{"osUsername":osUsername}
            }).then(rs=>{
                if (rs.data==0) {
                    $(".required").eq(3).text("*");
                    this.flag.checkOsuserName=false;
                    return
                }
                $(".required").eq(3).text("√");
                this.flag.checkOsuserName=true
            })
        },
    checkPassword:function (pwd) {
        axios({
            url:'service/checkPassword',
            params:{"pwd":pwd}
        }).then(rs=>{
            if (rs.data==0) {
                $(".required").eq(4).text("*");
                this.flag.checkPassword=false;
                return
            }
            $(".required").eq(4).text("√");
            this.flag.checkPassword=true

        })
    },
    checkPasswordMore:function (pwd,pwd2) {
        axios({
            url:'service/checkPasswordMore',
            params:{"pwd":pwd,"pwd2":pwd2}
        }).then(rs=>{
            if (rs.data==0) {
                $(".required").eq(5).text("*");
                this.flag.checkPasswordMore=false;
                return
            }
            $(".required").eq(5).text("√");
            this.flag.checkPasswordMore=true
        })
    },
    doInsert:function () {
        if (true==this.flag.checkPassword==this.flag.checkOsuserName==this.flag.checkUnixHost==this.flag.checkAccountIdcardNo==this.flag.checkAccountName==this.flag.checkPasswordMore){
            axios({
                url:'service/doInsert',
                method:'post',
                data: this.service
            }).then(rs=>{
                if (rs.data == 0) {
                    parent.layer.message=-1
                }else {
                    parent.layer.message=1
                }
                this.close()
            })
        }else {
            layer.msg("不符合条件")
        }
    },
        close:function () {
            let index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            parent.layer.close(index);//通过父窗口layer对象关闭子窗口
        }

    }
})